<div id="block-text" class="block">
  <div class="secondary-navigation">
    <ul>
      <li class="active first"><a href="#block-text">  <%=h @product.name %></a></li>
      <li><a href="#block-comments">评论</a></li>
      <li><a href="#block-contacts">咨询</a></li>
      <li><%unless @product0.blank?%><%=link_to '上一商品',product_path(@product0.first.id.to_s + '-' + @product0.first.name ) %> <%end%></li>
      <li><%unless @product2.blank?%><%=link_to '下一商品',product_path(@product2.first.id.to_s + '-' + @product2.first.name ) %><%end%></li>
      
    </ul>
    <div class="clear"></div>
  </div>
  <div class="content">
    <h2 class="title"><%=h @product.name %></h2>
    <div class="inner">
      <p class="first">
        <!--
<%@product.product_images.each do |image|%>
  <%#= image_tag(image.try(:image).try(:url).to_s , :size=>'600x400') %>
<%end%>
-->
         
      </p>
      <div id="product-images">
        
        <div id="main-image">
          <%=  image_tag(@product.product_images.first.try(:image).try(:url).to_s) %>
        </div>
        <div id="thumbnails">
          <ul id="product-thumbnails" class="thumbnails" style="">
            <%@product.product_images.each do |image|%>
              <li style="" > <%= link_to_function  image_tag(image.image.url(:thumb)) , "setImage(this,'#{image.image.url(:product)}')" ,:style => '' %></li>
            <%end%>
          </ul>
          
          <% javascript_tag  do  %>
            function setImage(obj,srcValue){
            $$('#product-thumbnails li').each(function(n){n.className = ''});
            $$('#main-image img')[0].src= srcValue;
            obj.parentNode.className = 'selected'
          
            }
          
          <%end %>  
        </div>
        
      </div>
      <p style="clear: both;"> </p>
    </div>
    <p style="clear: both;"> </p>
    <hr/>
    <p style="clear: both;"> </p>
    <% form_for :cart_item, :url => cart_items_path,:html=>{:class=>'form' ,:method => :post,:id=>'form'} do |f| %>
                                       
      <table class="table">
        <tbody>
        
          <tr class="odd">
            <td width="60px">序列号:</td>
            <td width="180px">  <%=h @product.serial %></td>
            <td  width="60px">商户:  </td>
            <td><%=link_to @product.user.try(:name), user_path(@product.user_id.to_s + '-' + @product.user.try(:name).to_s )%> 
            <a href="/products?keywords=<%= to_seo(@product.user.try(:name).to_s) %>"> 用户产品</a> </td>
          </tr>
          <tr class="odd">
            <td>种类:</td>
            <td>  <%=h @product.name %></td>
            <td>名称:</td>
            <td>    <%=h @product.name %>    </td>
          </tr>
          <tr class="odd">
            <td>颜色:</td>
            <td>   <%=h @product.color.name %></td>
            <td>种类:</td>
            <td>  <%=h @product.sort.name %></td>
          </tr>
          <tr class="odd">
            <td>价格:</td>
            <td> <%=h @product.price %></td>
            <td>等级:</td>
            <td>  <%=h Product::RANK[@product.rank] %></td>
          </tr>    
          <tr class="odd">
            <td>状态:</td>
            <td> <%=h Product::STATE[@product.state] %></td>
            <td><%#= 数量:%></td>
            <td>            <%#= f.select :quantity,(1..99).map{|n|[n,n]}%>
            <%= f.hidden_field :id,:value => @product.to_param %></td>
          </tr>
          <tr class="odd">
            <td>说明:</td>
            <td  colspan="3">        <%=h @product.introduction %></td>
          </tr>
          <tr class="odd">
            <td></td>
            <td >   </td>
            <td></td>
            <td > <%#= <input type="submit" value='加入购物车' class="button"  />%>  </td>
          </tr>
        </tbody>
      </table>
    <% end %>
    <% form_tag alipay_product_path(@product),:html=>{:class=>'form' ,:method => :post,:id=>'form'} do |f| %>

      <table class="table">
        <tbody>
          <tr class="odd">
            <td></td>
            <td >   </td>
            <td></td>
            <td >   <input  src="/images/button_alipay1.gif"  type="image" />  </td>
          </tr>
        </tbody>
      </table>
    <% end %>
  </div>
  
  
</div>


<div id="block-comments" class="block">
  <div class="secondary-navigation">
    <ul>
      <li class="first"><a href="#block-text">  <%=h @product.name %></a></li>
      <li class="first active"><a href="#block-comments">评论</a></li>
    <li  class=""><a href="#block-contacts">咨询</a></li>  </ul>
    <div class="clear">   </div>
  </div>
  <div class="content">
    <h2 class="title"><%= link_to '更多商品评论' ,product_product_comments_path(@product) %></h2>
    <div class="inner">
      
      <% form_for ProductComment.new ,:url => product_product_comments_path(@product) ,:html => {:class => "no-floating form"} do |f| %>
        <input id="product_comment_user_id" type="hidden" name="product_comment[user_id]" value="<%=session[:user_id]%>"/>
        <%= f.hidden_field :product_id %>
        <table class="table">
          <tbody>
            <tr class="odd">
              <td>评论</td><td><%= f.text_area :content,:size => "50x5" %></td>
            </tr>
            <tr class="odd">
              <td>调整价格</td><td><%= f.text_field :price %>&nbsp;注：正为加价，负为减价</td>
            </tr>
            <tr class="odd">
              <td></td>   
              <td align="right" >  <input type="submit" value='提交' class="button"  /> </td>
            </tr>
          </tbody>
        </table>
      <% end %>
    </div>
  </div>                               
</div>


<div id="block-contacts" class="block">
  <div class="secondary-navigation">
    <ul>
      <li class="first"><a href="#block-text">  <%=h @product.name %></a></li>
      <li class=""><a href="#block-comments">评论</a></li>
    <li  class="active"><a href="#block-contacts">咨询</a></li>  </ul>
    <div class="clear">   </div>
  </div>
  <div class="content">
    <h2 class="title"><%= link_to '更多咨询' ,product_product_contacts_path(@product) %></h2>
    <div class="inner">
      <% form_for  @product_contact,:url =>product_product_contacts_path(@product),:html => {:class => "no-floating form"} do |f| %>
        <input id="product_contact_user_id" type="hidden" name="product_comment[user_id]" value="<%=session[:user_id]%>"/>
        <%= f.hidden_field :product_id %>
        <table class="table">
          <tbody>
            <tr class="odd">
              <td>问题</td><td><%= f.text_area :name ,:size => "50x5" %></td>
            
            </tr>
            <tr class="odd">
              <td>手机或电话</td><td><%= f.text_field :phone%></td>
            
            </tr>
            <tr class="odd">
              <td>邮件</td><td><%= f.text_field :email %></td>
            
            </tr>
            <tr class="odd">
              <td></td>   
              <td align="right" >  <input type="submit" value='提交' class="button"  /> </td>
            </tr>
          </tbody>
        </table>
      <% end %>
    </div>
  </div>                               
</div>
